#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

UDEB_CFLAGS=-Os -I.

build: build-stamp
build-stamp:
	dh_testdir
	$(MAKE) all libiw.a
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	$(MAKE) realclean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) install install-static PREFIX="`pwd`/debian/tmp"
	dh_link
	dh_install
	install -D debian/pre-up debian/wireless-tools/etc/network/if-pre-up.d/wireless-tools
	install -D debian/post-down debian/wireless-tools/etc/network/if-post-down.d/wireless-tools
	$(MAKE) clean
	$(MAKE) BUILD_NOLIBM=y CFLAGS="$(UDEB_CFLAGS)" PREFIX="`pwd`/debian/tmp"
	dh_install -pwireless-tools-udeb iwconfig iwgetid sbin/
	dh_install -plibiw29-udeb libiw.so.29 lib/

binary-indep: build install

binary-arch: build install
	dh_testdir
	dh_testroot
#	dh_installmanpages
	dh_installdocs
	dh_installchangelogs CHANGELOG.h 
	dh_installinit --no-start -- start 40 S .
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs --add-udeb=libiw29-udeb
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install
